﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;
using Newtonsoft.Json.Serialization;
using DataModel.PublicModel.Typedef;

namespace DataModel.Receive
{
    /// <summary>
    /// 接收报文头的基本定义
    /// </summary>
    public abstract class HeaderBase
    {
        Operator operation;//操作类型定义
        string user;
        string stage;//站点名称（STRING）
        /// <summary>
        /// 操作类型
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "operation")]
        public Operator Operation
        {
            get
            {
                return operation;
            }

            set
            {
                operation = value;
            }
        }
        /// <summary>
        /// 站点名称（STRING）
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "stage")]
        public string Stage
        {
            get
            {
                return stage;
            }

            set
            {
                stage = value;
            }
        }
        /// <summary>
        /// 用户ID
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "user")]
        public string User
        {
            get
            {
                return user;
            }

            set
            {
                user = value;
            }
        }
    }
    /// <summary>
    /// 接收报文头的基本定义
    /// </summary>
    /// <typeparam name="T">报文DATA部分的基类</typeparam>
    public abstract class HeaderBase<T> : HeaderBase where T : IData, new()
    {
        T data;//数据空间
        /// <summary>
        /// 数据空间。此处为泛型。留待
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "data")]
        public T Data
        {
            get
            {
                if (data == null)
                    data = new T();
                return data;
            }

            set
            {
                data = value;
            }
        }
    }
}